<template>
  <a-card :bordered="false">
    <a-form layout="inline" @keyup.enter.native="searchQuery">
      <a-form-item label="任务编码">
        <a-input v-model="queryParam.instanceCode" />
      </a-form-item>
      <a-form-item label="任务名称">
        <a-input v-model="queryParam.instanceName" />
      </a-form-item>
      <a-form-item>
        <a-button type="primary" icon="search" @click="searchQuery">查询</a-button>
        <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
      </a-form-item>
    </a-form>
    <vxe-grid
      id="PerformancePlan"
      ref="vxeTable"
      v-bind="options"
      :columns="columns"
      :data="dataSource"
      @toolbar-button-click="toolbarButtonClickEvent"
      @checkbox-all="onSelectChange"
      @checkbox-change="onSelectChange"
    >
      <template v-slot:operate="{ row }">
        <a @click="handleResults(row)">查看结果</a>
        <a-divider v-has="'AssessmentInstance:check'" v-if="row.instanceStatus === '2'" type="vertical" />
        <a-dropdown v-has="'AssessmentInstance:check'" v-if="row.instanceStatus === '2'">
          <a class="ant-dropdown-link">更多<a-icon type="down" /></a>
          <a-menu slot="overlay">
            <a-menu-item>
              <a @click="handleEdit(row)">编辑</a>
            </a-menu-item>
            <a-menu-item>
              <a @click="handleVerify(row)">绩效审批</a>
            </a-menu-item>
          </a-menu>
        </a-dropdown>
      </template>
      <template v-slot:pager>
        <vxe-pager
          :layouts="layouts"
          :current-page.sync="ipagination.currentPage"
          :page-size.sync="ipagination.pageSize"
          :total="ipagination.total"
          @page-change="handlePageChange"
        >
        </vxe-pager>
      </template>
    </vxe-grid>
    <assessment-verify-modal ref="assessmentVerifyModal"  @ok="modalFormOk"/>
  </a-card>
</template>
<script >
import JSelectUserByDep from '@/components/jeecgbiz/JSelectUserByDep'
import AssessmentVerifyModal from './modal/AssessmentVerifyModal'
import { VxeTableMixin } from '@/mixins/VxeTableMixin'
import { filterDictTextByCache } from '@/components/dict/JDictSelectUtil'
// import { getAction, postAction } from '@/api/manage'
export default {
  name: 'AssessmenTask',
  mixins: [VxeTableMixin],
  components: {
    JSelectUserByDep,
    AssessmentVerifyModal
  },
  data() {
    return {
      columns: [
        // { type: 'checkbox', width: 50 },
        { type: 'seq', width: 60 },
        { field: 'instanceCode', title: '任务编码' },
        { field: 'instanceName', title: '任务名称' },
        { field: 'instanceStatus', title: '任务状态', slots: { default: ({ row }) => {
          return filterDictTextByCache('hr_instance_status', row.instanceStatus)
        } }},
        { field: 'remark', title: '说明' },
        { field: 'operate', title: '操作', width: 150, slots: { default: 'operate' }}
      ],
      url: {
        list: '/hr/assessment/instance/list',
        delete: '/hr/assessment/instance/delete',
        deleteBatch: '/hr/assessment/instance/deleteBatch'
        // queryResult: '/hr/assessment/instance/queryResult',

      }
    }
  },
  methods: {
    handleResults(row) {
      this.$refs.assessmentVerifyModal.loadData(row.instanceCode)
      this.$refs.assessmentVerifyModal.disableCheck = true
      this.$refs.assessmentVerifyModal.disableSubmit = true
      this.$refs.assessmentVerifyModal.title = '查看结果'
      this.$refs.assessmentVerifyModal.editModalVisible = true
    },
    handleVerify(row) {
      this.$refs.assessmentVerifyModal.loadData(row.instanceCode)
      this.$refs.assessmentVerifyModal.disableCheck = false
      this.$refs.assessmentVerifyModal.disableSubmit = true
      this.$refs.assessmentVerifyModal.title = '审核'
      this.$refs.assessmentVerifyModal.id = row.id
      this.$refs.assessmentVerifyModal.editModalVisible = true
    },
    handleEdit(row) {
      this.$refs.assessmentVerifyModal.loadData(row.instanceCode)
      this.$refs.assessmentVerifyModal.disableCheck = true
      this.$refs.assessmentVerifyModal.disableSubmit = false
      this.$refs.assessmentVerifyModal.title = '编辑'
      this.$refs.assessmentVerifyModal.editModalVisible = true
    }
  }
}
</script>
